USE [ServerMonitor]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DBFile_DBUsage]') AND parent_object_id = OBJECT_ID(N'[dbo].[DBFile]'))
ALTER TABLE [dbo].[DBFile] DROP CONSTRAINT [FK_DBFile_DBUsage]
GO
USE [ServerMonitor]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DBFile]') AND type in (N'U'))
DROP TABLE [dbo].[DBFile]
GO
USE [ServerMonitor]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[DBFile](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[DBUsageId] [int] NOT NULL,
	[DBFileId] [smallint] NOT NULL,
	[name] [nvarchar](256) NOT NULL,
	[FileType] [char](50) NULL,
	[FilePath] [nvarchar](256) NULL,
	[DiskFreeMB] [int] NULL,
 CONSTRAINT [PK_DBFile] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[DBFile]  WITH CHECK ADD  CONSTRAINT [FK_DBFile_DBUsage] FOREIGN KEY([DBUsageId])
REFERENCES [dbo].[DBUsage] ([Id])
GO

ALTER TABLE [dbo].[DBFile] CHECK CONSTRAINT [FK_DBFile_DBUsage]
GO


